<?php
// Autor (c) Miroslav Novak, www.platiti.cz
// Pouzivani bez souhlasu autora neni povoleno
// #Ver:PRV043#




function sqlconnect() {
	global $mysql;
	$dbconn = mysql_connect($mysql['server'], $mysql['login'], $mysql['password']);
	mysql_select_db($mysql['dbname']) or die(mysql_error());
	mysql_query("SET NAMES 'UTF-8'");
}

function sqlexecute($sql) {
	$res = mysql_query($sql) or trigger_error(mysql_error() . "<br/>SQL: ".$sql, E_USER_ERROR);
	return $res;
}

function sqlquery($sql) {
	$res = sqlexecute($sql);

	$ar = array();
	while($row = mysql_fetch_array($res)) {
		$ar[] = $row;
	}

	return $ar;
}

function toSql($text) {
	if (is_null($text)) {
		return "null";
	} else {
		return "'".mysql_real_escape_string($text)."'";
	}
}

function sqlbuilder_add_field_direct($name, $value) {
	global $sqlbuild_insert_names, $sqlbuild_insert_values, $sqlbuild_update_set;
	if ($sqlbuild_insert_names!='') $sqlbuild_insert_names.=',';
	if ($sqlbuild_insert_values!='') $sqlbuild_insert_values.=',';
	$sqlbuild_insert_values.=$sqlbuild_update_set."=".toSql($_REQUEST[$f]);
	if ($sqlbuild_update_set!='') $sqlbuild_update_set.=',';
	$sqlbuild_update_set.=$sqlbuild_update_set."=".toSql($_REQUEST[$f]);

	$fa.=$f."=".toSql($_REQUEST[$f]);

}


function sqlbuilder_add_field($name) {
}


?>
